<?php

     require_once('includes/common.inc.php');

     if (Request::IsMethod(Request::POST) && Request::IsAjaxRequest())
     {
         $name = Request::Post('name');
         $email = Request::Post('email');
         $phone = Request::Post('phone');
         $coaching = Request::Post('coaching');
         $wantToEnter = Request::Post('want_to_enter');
         $keepInformed = Request::Post('keep_informed');
         $message = Request::Post('message', '&nbsp;');

         $isValidParams = !empty($name) && !empty($phone) && Util::IsValidEmail($email);

         $res = Mailer::SENDING_FAILED;
         if ($isValidParams)
         {
             $res = Mailer::sendRequest($name, $email, $phone, $coaching, $wantToEnter, $keepInformed, $message);
         }
         
         echo json_encode((int)$res);
     }
     else
     {
         Request::Redirect('/');
     }